package com.birdboot.test;

import java.util.Arrays;

public class SpiltDemo {
    public static void main(String[] args) {
        String line = "1=2=3=4=5=====";

        String[] data = line.split("=");
        System.out.println(Arrays.toString(data));

        data = line.split("=",2);
        System.out.println(Arrays.toString(data));

        data = line.split("=",8);
        System.out.println(Arrays.toString(data));

        //当limit>最大可拆分项时，返回的数组为最大可拆分项（默认连续拆分出的空串也会保留）
        data = line.split("=",20);
        System.out.println(Arrays.toString(data));

        //当limit为0时一个参数的split效果一致
        data = line.split("=",0);
        System.out.println(Arrays.toString(data));

        //当limit<0时,应拆尽拆
        data = line.split("=",-1);
        System.out.println(Arrays.toString(data));
    }
}
